<?php
include './couSQL.php';

header('Content-Type:application/json; charset=utf-8'); #返回json

$input = file_get_contents('php://input'); 
// echo $input;
$arr = json_decode($input, true);  //转化为普通数据

$couSQL = new CouSql();
$status = $couSQL -> compareStu2([
    'studentId' => $arr['stu_id'],
    'courseId' => $arr['cou_num'],
    'courseYaer' => $arr['cou_year'],
    'courseTerm' => $arr['cou_term'],
]);
if ($status === -1){
    $result = [
        'code' => '1',
        'msg' => '学生不存在',
    ];
} else if ($status === -2) {
    $result = [
        'code' => '2',
        'msg' => '课程不存在',
    ];
}
else if ($status === -3) {
    $result = [
        'code' => '3',
        'msg' => '学生已选课',
    ];
}
else{
    $result = [
        'code' => '0',
        'msg' => '选课修改成功',
    ];
}
echo json_encode($result);
